<div class="content-wrapper" [@routerTransition]>
    <sub-header idName="Administration.FrontendPages" [title]="'FrontendPage' | localize">
        <div role="actions">
            <div class="form-group form-md-line-input form-md-floating-label no-hint mr-3" >
                <select id="backEndModuleId" name="backEndModuleId" class="form-control edited" [(ngModel)]="backEndModuleId" (change)="getListData()">
                    <option *ngFor="let rec of backendPageList" [value]="rec.value">
                        {{rec.name}}
                    </option>
                </select>
            </div>
            <button (click)="createNews()" *ngIf="'Pages.Administration.FrontendPage.Create' | permission"
                class="btn btn-primary blue mr-1"><i class="fa fa-plus"></i> {{"CreateNew" | localize}}
            </button>
            <button (click)="changeState(true)" *ngIf="'Pages.Administration.FrontendPage.Edit' | permission"
                class="btn btn-primary blue mr-1"><i class="fa fa-book"></i> {{"Release" | localize}}
            </button>
            <button (click)="changeState(false)" *ngIf="'Pages.Administration.FrontendPage.Edit' | permission"
                class="btn btn-warning mr-1"><i class="fa fa-reply"></i> {{"CancelRelease" | localize}}
            </button>
            <button (click)="delete()" *ngIf="'Pages.Administration.FrontendPage.Delete' | permission" class="btn btn-warning">
                <i class="fa fa-trash"></i> {{"Delete" | localize}}
            </button>
        </div>
    </sub-header>
    <!-- /.content-header -->
    <!-- Main content -->
    <section class="content d-flex flex-column flex-column-fluid">
        <div [class]="containerClass">
            <div class="card card-custom gutter-b">
                <div class="card-body">
                    <div class="row">
                        <tabset class="ui-tabs-nav">
                            <tab  (selectTab)="onTabSelect($event,i)" [hidden]="!item.isShow" heading="{{item.name}}" [active]="i === currentIndex"  *ngFor="let item of actionNames,let i = index">
                           </tab>
                        </tabset>
                    </div>

                    <div class="row align-items-center">
                        <!--<Primeng-TurboTable-Start>-->
                        <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                            <p-table #dataTable sortMode="multiple" 
                                [value]="primengTableHelper.records"
                                rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false"
                                [lazy]="true" [responsive]="primengTableHelper.isResponsive"
                                [resizableColumns]="primengTableHelper.resizableColumns"
                                [(selection)]="selectedDatas"
                                dataKey="id" 
                                selectionMode="multiple">
                                <ng-template pTemplate="header">
                                    <tr>
                                        <th style="width:38px">
                                            <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
                                        </th>
                                        <th style="width: 130px"
                                        [hidden]="!(['Pages.Administration.FrontendPage.Create', 'Pages.Administration.FrontendPage.Edit', 'Pages.Administration.FrontendPage.Delete'] | permissionAny)">
                                        {{'Actions' | localize}}
                                        </th>
                                        <th style="width:140px">
                                            {{'Name' | localize}}
                                        </th>
                                        <th style="width:160px">
                                            {{'FrontendPageView' | localize}}
                                        </th>
                                        <th style="width:120px">
                                            {{'IsDetailPage' | localize}}
                                        </th>
                                        <th style="width:120px">
                                            {{'ReleaseState' | localize}}
                                        </th>
                                        <th style="width:120px">
                                            {{'Order' | localize}}
                                        </th>
                                        <th style="width:140px">
                                            {{'Controller' | localize}}
                                        </th>
                                        <th style="width:140px">
                                            {{'Action' | localize}}
                                        </th>
                                        <th style="width:140px">
                                            {{'Url' | localize}}
                                        </th>
                                        <th style="width:120px">
                                            {{'Target' | localize}}
                                        </th>
                                        <th style="width:120px">
                                            {{'CreationTime' | localize}}
                                        </th>
                                        <th style="width: 140px">
                                            {{'MotifyTime' | localize}}
                                        </th>
                                    </tr>
                                </ng-template>
                                <ng-template pTemplate="body" let-record="$implicit">
                                    <tr>
                                        <td style="width: 38px">
                                            <p-tableCheckbox [value]="record" (click)="$event.stopPropagation()">
                                            </p-tableCheckbox>
                                        </td>
                                        <td
                                        [hidden]="!(['Pages.Administration.FrontendPage.Create', 'Pages.Administration.FrontendPage.Edit', 'Pages.Administration.FrontendPage.Delete'] | permissionAny)">
                                        <div class="btn-group" dropdown placement="bottom left">
                                                <button id="dropdownButton" type="button"
                                                    class="btn btn-primary btn-xs2 dropdown-toggle blue" dropdownToggle
                                                    aria-controls="dropdownMenu">
                                                    <i class="fa fa-cog"></i><span class="caret"></span>
                                                    {{"Actions" | localize}}
                                                </button>
                                                <ul id="dropdownMenu" class="dropdown-menu" role="menu" *dropdownMenu
                                                    aria-labelledby="dropdownButton">
                                                    <li *ngIf="'Pages.Administration.FrontendPage.Create' | permission"
                                                        role="menuitem">
                                                        <a class="dropdown-item" href="javascript:;"
                                                            (click)="copy(record)">{{'Copy' |localize}}</a>
                                                    </li>
                                                    <li *ngIf="'Pages.Administration.FrontendPage.Edit' | permission"
                                                        role="menuitem">
                                                        <a class="dropdown-item" href="javascript:;"
                                                            (click)="edit(record)">{{'Edit' | localize}}</a>
                                                    </li>
                                                    <li *ngIf="'Pages.Administration.FrontendPage.Delete' | permission"
                                                         role="menuitem">
                                                        <a class="dropdown-item" href="javascript:;"
                                                            (click)="deleteSingle(record)">{{'Delete' | localize}}</a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </td>

                                        <td style="width: 140px">
                                            <span class="p-column-title"> {{'Name' | localize}}</span>
                                            <a title="{{record.name}}" href="javascript:void(0)"
                                                (click)="edit(record)">{{record.name}}</a>
                                        </td>
                                        <td style="width: 160px">
                                            <a href="javascript:void(0)" *ngIf="'Pages.Administration.FrontendPageView' | permission" 
                                               (click)="goPageView(record)">{{'LookOver' |localize}}</a>
                                        </td>
                                        <td style="width: 120px">
                                            <span class="p-column-title"> {{'IsDetailPage' | localize}}</span>
                                            <span class="label label-success label-inline" *ngIf="record.isDetailPage">{{'Yes' | localize}}</span>
                                            <span class="label label-dark label-inline" *ngIf="!record.isDetailPage">{{'No' | localize}}</span>
                                        </td>
                                        <td style="width: 120px">
                                            <span class="p-column-title"> {{'ReleaseState' | localize}}</span>
                                            <span class="label label-success label-inline" *ngIf="record.isActive">{{'Yes' | localize}}</span>
                                            <span class="label label-dark label-inline" *ngIf="!record.isActive">{{'No' | localize}}</span>
                                        </td>
                                        <td style="width: 120px">
                                            <span class="p-column-title"> {{'Order' | localize}}</span>
                                            {{record.order}}
                                        </td>
                                        <td style="width: 140px">
                                            <span class="p-column-title"> {{'Controller' | localize}}</span>
                                            {{record.controllerName}}
                                        </td>
                                        <td style="width: 140px">
                                            <span class="p-column-title"> {{'Action' | localize}}</span>
                                            {{record.actionName}}
                                        </td>
                                        <td style="width: 140px">
                                            <span class="p-column-title"> {{'Url' | localize}}</span>
                                            {{record.url}}
                                        </td>
                                        <td style="width: 120px">
                                            <span class="p-column-title"> {{'Target' | localize}}</span>
                                            {{record.target}}
                                        </td>
                                        <td style="width: 120px">
                                            <span class="p-column-title"> {{'CreationTime' | localize}}</span>
                                            {{record.creationTime | luxonFormat:'F'}}
                                        </td>
                                        <td style="width: 140px">
                                            <span class="p-column-title"> {{'MotifyTime' | localize}}</span>
                                            {{record.lastModificationTime | luxonFormat:'yyyy-MM-dd HH:mm:ss'}}
                                        </td>
                                    </tr>
                                </ng-template>
                            </p-table>
                            <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                                {{'NoData' | localize}}
                            </div>
                            <div class="primeng-paging-container">
                                <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                    (onPageChange)="getListData($event)"
                                    [totalRecords]="primengTableHelper.totalRecordsCount"
                                    [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage"
                                    [showCurrentPageReport]="true"
                                    [currentPageReportTemplate]="'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount">
                                </p-paginator>
                            </div>
                        </div>
                        <!--<Primeng-TurboTable-End>-->
                    </div>
                </div>
            </div>
        </div>
    </section>                                                
</div>

<pageview-modal #pageViewModal (callback)="reloadPage()"></pageview-modal>
<create-or-edit-page-modal #createOrEditPageModal (callback)="reloadPage()"></create-or-edit-page-modal>
